package com.dc.designPattern._11_proxy.impl._2_dynamic;

/**
 * Description: 动态代理_客户端
 * @author: gdc
 * @date: 2021/4/14
 * @version 1.0
 */
public class Client {

    public static void main(String[] args){
        // step 1 创建被代理对象
        ITeacherDao teacherDao = new TeacherDao();

        // step 2 给目标对象，创建代理对象，可以转换为 ITeacherDao
        ITeacherDao proxyTeacher = (ITeacherDao) new ProxyFactory(teacherDao).getProxyInstance();

        // proxyInstance=class com.sun.proxy.$Proxy0 内存中动态生成了代理对象
        System.out.println("proxyInstance=" + proxyTeacher.getClass());

        // step 3 通过代理对象，调用目标对象方法
        proxyTeacher.teach();

        System.out.println("---------------------------------------------------");

        proxyTeacher.sayHello("秦羽");

    }
}
